/**
 * Copyright (C) 2009 alex <me@alex.0x08.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uber.netbsd.community.action;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import uber.netbsd.community.BzSessionBean;
import uber.netbsd.community.Loggered;
import uber.netbsd.community.dao.Person;


/**
 * This was originally taken from Buzooky, sample application for Stripes Framework
 * 
 * Base ActionBean that all ActionBeans in our app
 * will extend.
 *
 * @author Tim Fennell
 * @author alex (i removed all stuff related to Bug object)
 */
public abstract class BaseActionBean extends Loggered implements ActionBean {
    private ActionBeanContext context;

   
    /**
     *
     * @return support bean instance from user's session
     */
    protected BzSessionBean getSupportBean() {
        return (BzSessionBean) getContext().getRequest().getSession().getAttribute("bzManager");
    }

    /**
     *
     * @return current logged user from user's session
     */
    protected Person getCurrentUser() {

       BzSessionBean bean = getSupportBean();
       if (bean==null)
           return null;

       return bean.getCurrentUser();
    }

    public void setContext(ActionBeanContext context) {
        this.context = (ActionBeanContext) context;
    }

    /** Gets the ActionBeanContext set by Stripes during initialization. */
    public ActionBeanContext getContext() {
        return this.context;
    }

    
}
